<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 

class OrderModel extends BaseModel
{

    var $table  = 'order';	

    var $_page_rows = 20;	
	

    function show($order='',$v='',$word='')
    {   
	
	     empty($order)?$order = 'add_time desc':'';
		 
		 $num = count($word);
		 $i = 0;
		 $conditions='';
		 foreach($word as $key => $value)
		 {
			 $i++; 	
		     if($value)
		     {
		      $conditions .= " company like '%{$value}%' ";
			      if($i<$num)
			      {
		           $conditions .= " and ";							   
			      }			  
		     }
		 }	 
	  	
	      //分页时，一定是先调用page函数，再调用S_Sql_Exe函数
		 $info['page'] = $this->Page(array('conditions' =>"{$conditions}",'url' => 'admin/?app=order&act=index&v='.$v));		
		 $info['data'] = $this->S_Sql_Exe(array('fields' =>'id,company,name,telphone,add_time,see,deal','conditions' =>"{$conditions}",'order' =>"{$order}",'limit' =>$info['page']['sql_limit']));
    
		 return $info;
        
    }

    /* 插入数据 */
    function del($id ='')
    {      
		return $this->D_Sql_Exe(array ('conditions' =>"id = '{$id}' "));
        
    }


    /* 修改数据 */
    function oneedit($str,$id ='',$data = '')
    {  	      
		return $this->IU_Sql_Exe(array ('data' => array("{$str}"=>"$data"),'mode' => 'UPDATE','conditions' =>"id = '{$id}' "));    
    }

    /* 修改数据展示 */
    function oneshow($id ='')
    {    	      
		 $info = $this->S_Sql_Exe(array('fields' =>'*','conditions' =>"id='{$id}'",'return' =>'one'));
		     
		 return $info;
        
    }



}








?>